package com.annotation;

import java.lang.reflect.Method;

public class User {
    private String name;
    private int age;

    @HelloWorld(value = "test")
    public void create() {
        System.out.println(name + "===" + age);
    }

    public static void main(String[] args) {
        Method[] declaredMethods = User.class.getDeclaredMethods();
        for (int i = 0; i < declaredMethods.length; i++) {
            HelloWorld annotation = declaredMethods[i].getAnnotation(HelloWorld.class);
            if (annotation == null) {
                System.out.println(declaredMethods[i].getName() + "没有HelloWorld注解");
            } else {
                System.out.println(declaredMethods[i].getName());
                System.out.println(annotation.value());
                System.out.println(annotation.age());
            }
        }
    }
}
